/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package linkeddata.arida.ufc.br.test;

import java.util.ArrayList;
import java.util.List;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.XML;

/**
 *
 * @author jeovane
 */
public class Json2XML {
    public static void main(String[] args) throws JSONException {
        String xmlString = "<?xml version=\"1.0\"?>" + 
                    "<paises>" + 
                        "<pais sigla=\"BR\">" + 
                            "<nome>Brasil</nome>" + 
                            "<populacao>196655014</populacao>" + 
                        "</pais>" + 
                        "<pais sigla=\"AR\">" + 
                            "<nome>Argentina</nome>" + 
                            "<populacao>40764561</populacao>" + 
                        "</pais>" + 
                    "</paises>";
        
        JSONObject paisesJson = XML.toJSONObject(xmlString);
        //System.out.println(paisesJson.toString());
        List<Integer> list = new ArrayList<Integer>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        
        for (int i = 0; i < list.size(); i++) {
            if (i < list.size() - 1) {
                System.out.print(list.get(i) + "»");
            } else {
                System.out.print(list.get(i) + "\n");
            }
        }
    }
}
